<ul class="subNavig">
        <li><a href="{$data.root}?input=list_of_clients">Clients</a></li>
        <li><a href="{$data.root}?input=list_of_users">Users</a></li>
        <li><a href="{$data.root}?input=list_of_tariffs">Tariffs</a></li>
        <li><a href="{$data.root}?input=fixed_expense">Fixed expenses</a></li>
    </ul>
{include $data.pathToError}
<script type="text/javascript">
    {literal}
        
    $(document).ready(function() {
        $(".float").change(function() {
            makeFloat(".float");
        });
        $("#associatedClients").multiselect(); 
    });
    {/literal}
</script>
<h2 class="pageTitle">Edit user</h2>

<form class="adding" action="{$data.root}?input=edit_user&user={$smarty.request.user}" method="post" onsubmit="return checkAdd_user(
                                                                    $('#name').val(),
                                                                    $('#surname').val(),
                                                                    $('#login').val(),
                                                                    preprocessPassword('#password'),
                                                                    $('#client').val(),
                                                                    $('#userlevel').val(),
                                                                    $('input:radio[name=user[active]]:checked').val())
                                                                    ">
    <table class="tableForm">
        <tr>
            <td>
                <label for="name">Name <span class="red">*</span> </label>
            </td>
            <td>
                <input name="user_data[name]" id="name" type="text" value="{$data.user_data.name}" />
            </td>
        </tr>
        <tr>
            <td>
                <label for="surname">Surname<span class="red">*</span> </label>
            </td>
            <td>
                <input name="user_data[surname]" id="surname" type="text" value="{$data.user_data.surname}" />
            </td>
        </tr>
        <tr>
            <td>
                <label for="email">Email<span class="red"></span> </label>
            </td>
            <td>
                <input name="user_data[email]" id="email" type="text" value="{$data.user_data.email}" />
            </td>
        </tr>
        <tr>
            <td>
                <label for="telephone">Telephone<span class="red"></span> </label>
            </td>
            <td>
                <input name="user_data[telephone]" id="telephone" type="text" value="{$data.user_data.telephone}" />
            </td>
        </tr>
        <tr>
            <td>
                <label for="login">Login<span class="red">*</span> </label>
            </td>
            <td>
                <input name="user_data[login]" id="login" type="text" value="{$data.user_data.login}" />
            </td>
        </tr>
        <tr>
            <td>
                <label for="password">Password<span class="red">*</span> </label>
            </td>
            <td>
                <input name="user_data[password]" id="password" type="password" />&nbsp;<label class="hide" for="passwordShort">This password is short (min. 6 chars)!</label>
            </td>
        </tr>
        <tr>
            <td>
                <label for="client">Client<span class="red">*</span> </label>
            </td>
            <td>
                <select name="user_data[client]" size="1" id="client">
                    <option value="">Please select</option>
                    {foreach $data.clients as $key => $client}
                        <option {if $smarty.session.user.user_type_id!=$smarty.const.USER_TYPE_CLIENT && $client.bad_payer==1}class="badPayer"{/if} {if $client.klient_id==$data.user_data.client}selected="selected"{/if} value="{$client.klient_id}">{$client.name}</option>
                    {/foreach}
                </select>
            </td>
        </tr>
        <tr>
            <td>
                <label for="userlevel">User level<span class="red">*</span> </label>
            </td>
            <td>
                <select name="user_data[userlevel]" size="1" id="userlevel" onchange="showAssociatedClients(this.value,'{$smarty.const.USER_TYPE_CLIENT}')">
                    <option value="">Please select</option>
                    {foreach $data.userLevels as $key => $level}
                        <option {if $key==$data.user_data.userlevel}selected="selected"{/if} value="{$key}">{$level}</option>
                    {/foreach}
                </select>
            </td>
        </tr>
        <tr {if $data.user_data.userlevel==$smarty.const.USER_TYPE_CLIENT}style="display: table-row;"{else}style="display: none;"{/if} id="associatedClientsForm">
            <td>
                <label for="associatedClients">Associated clients<span class="red"></span> </label>
            </td>
            <td>
                <select name="user_data[associatedClients][]" size="10" id="associatedClients" multiple="" style="width: 500px">
                    {foreach $data.clients as $key => $client}
                        <option value="{$client.klient_id}" {if in_array($client.klient_id,$data.user_data.associatedClients) && ($client.klient_id!=$data.user_data.client)}selected="selected"{/if}>{$client.name}</option>
                    {/foreach}
                </select>
            </td>
        </tr>
        <tr>
            <td>
                <label for="active">Active<span class="red">*</span> </label>
            </td>
            <td>
                <input name="user_data[active]" type="radio" value="1" {if 1==$data.user_data.active}checked="checked"{/if} /> Yes <br/>
                <input name="user_data[active]" type="radio" value="0" {if 0==$data.user_data.active}checked="checked"{/if}/> No
            </td>
        </tr>
        <tr>
            <td>
                <label for="active">Prefered to protocol<span class="red"></span> </label>
            </td>
            <td>
                <input name="user_data[prefered]" type="radio" value="1" {if 1==$data.user_data.prefered}checked="checked"{/if} /> Yes <br/>
                <input name="user_data[prefered]" type="radio" value="0" {if 0==$data.user_data.prefered}checked="checked"{/if} /> No
            </td>
        </tr>
        <tr>
            <td>
                <label for="notify">Send notify always if Responsible<span class="red"></span> </label>
            </td>
            <td>
                <input name="user_data[notify]" type="radio" value="1" id="notify" {if 1==$data.user_data.notify}checked="checked"{/if} /> Yes <br/>
                <input name="user_data[notify]" type="radio" value="0" {if 0==$data.user_data.notify}checked="checked"{/if} /> No
            </td>
        </tr>
        <tr class="submitRow">
            <td>
                <input name="action" value="edit_user" type="hidden" />
            </td>
            <td>
                <input type="submit" value="Edit user" name="edit_user" /> &nbsp; 
                <span class="red">* Required</span>
            </td>
            <td></td>
        </tr>
    </table>
</form>